trigger CaseAccountteamSE on Case (before insert, before update) {
    set<ID> AccountIDs = new set<ID>();
    map<ID,AccountTeamMember> AcctTeamMap=new Map<ID,AccountTeamMember>();
    for(Case c:Trigger.new){
        AccountIDs.add(c.accountid);
    }
    //make bulk safe by executing soql only once
    for(AccountTeamMember at:[Select a.UserId,a.User.Name,a.TeamMemberRole, a.Id, a.AccountId 
                                From AccountTeamMember a 
                                where a.TeamMemberRole='Sales Engineer' and a.AccountId in :AccountIDs]){
        AcctTeamMap.put(at.Accountid,at);
    }
    for(Case c:Trigger.new){
        if(AcctTeamMap.containsKey(c.AccountId)){
            c.Account_SE__c=AcctTeamMap.get(c.AccountId).User.Name;
        }
    }
    
}